package com.fanghuaiming.service.order.impl;

import com.fanghuaiming.dao.mapper.log.LogMapper;
import com.fanghuaiming.dao.mapper.order.OrderMapper;
import com.fanghuaiming.dao.model.log.HisLog;
import com.fanghuaiming.dao.model.order.Order;
import com.fanghuaiming.service.order.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/****
 * @description:
 * @version:1.0.0
 * @author fanghuaiming
 * @data Created in 2020/11/25 下午5:34
 *
 */
@Service
@Slf4j
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private LogMapper logMapper;


    @Transactional
    @Override
    public void insertOrder(Order order) {
        testB(order);
    }

    private void testA(Order order) {
        log.info("============业务开始============");
        orderMapper.insertOrder(order);
        if (order.getFlag()==2) {
            int i = 1 / 0;
        }
        logMapper.insertLog(new HisLog(1L,"test"));
        log.info("============业务结束============");
    }

    private void testB(Order order) {
        log.info("============业务开始============");
        orderMapper.insertOrder(order);
        logMapper.insertLog(new HisLog(2L,"test"));
        if (order.getFlag()==2) {
            int i = 1 / 0;
        }
        log.info("============业务结束============");
    }
}
